<template>
  <header class="header">
    <h1>todos</h1>
    <input
      class="new-todo"
      placeholder="请输入任务名称"
      autofocus
      v-model="text"
      @keyup.enter="add"
    />
  </header>
</template>
<script>
export default {
  data() {
    return {
      text: '',
    }
  },
  name: 'TodoHeader',
  props: {},
  methods: {
    add() {
      this.$emit('add', this.text)
      this.text = ''
    },
  },
}
</script>
<style lang="less" scoped></style>
